﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using MixScript.BLL;
using MixScriptWeb.control;
using MixScript.BLL.FI;
using System.Globalization;

namespace MixScriptWeb.Accounting
{
    public partial class detailViewGRN : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dthdr = new DataTable();
            cAccHeader gaj = new cAccHeader();
            string editID = Request.QueryString["slipid"];
            dthdr = gaj.loadJournalHeaderGRN(editID);
            if (dthdr.Rows.Count > 0)
            {

                lblsjnot.Text = "SJ No";
                lblgrnnot.Text = "DN No";
                lblsuppliert.Text = "Customer";
                lblponot.Text = "Invoice No";
                lblSJ.Text = dthdr.Rows[0].ItemArray[0].ToString(); //slipno
                // General Journal
                if (lblSJ.Text.Contains("U"))
                    lblTitle.Text = "General Journal Voucher";
                //Cash Recieve
                else if (lblSJ.Text.Contains("CR"))
                {
                    lblTitle.Text = "Purchase Journal Voucher";
                    lblsjnot.Text = "PJ No";
                    lblgrnnot.Text = "GRN No";
                    lblsuppliert.Text = "Supplier";
                    lblponot.Text = "PO No";
                }
                //Cash payment
                else if (lblSJ.Text.Contains("CP"))
                {
                    lblTitle.Text = "Purchase Journal Voucher";
                    lblsjnot.Text = "PJ No";
                    lblgrnnot.Text = "GRN No";
                    lblsuppliert.Text = "Supplier";
                    lblponot.Text = "PO No";
                }
                //Bank Recieve Journal
                else if (lblSJ.Text.Contains("BR"))
                    lblTitle.Text = "Bank Recieve Journal Voucher";
                //Bank Payemnt Journal
                else if (lblSJ.Text.Contains("BP"))
                    lblTitle.Text = "Bank Payment Journal Voucher";
                //Account Recieve Journal
                else if (lblSJ.Text.Contains("AR"))
                    lblTitle.Text = "Account Recieve Journal Voucher";
                //Bank Payemnt Journal
                else if (lblSJ.Text.Contains("AP"))
                    lblTitle.Text = "Account Payment Journal Voucher";



                lblGRNNo.Text = dthdr.Rows[0].ItemArray[1].ToString(); //curr
                //lbldesc.Text = dthdr.Rows[0].ItemArray[3].ToString(); //desc
                lblDate.Text = String.Format("{0:dd-MMM-yyyy}", dthdr.Rows[0].ItemArray[2].ToString()); //date
                lblSupplier.Text = dthdr.Rows[0].ItemArray[3].ToString(); //curr
                lblPoNo.Text = dthdr.Rows[0].ItemArray[4].ToString(); //curr
                lblAmount.Text = string.Format(new CultureInfo("en-IN"), "{0:c}", dthdr.Rows[0].ItemArray[5].ToString().ToString()); //curr

            }

            gvList.DataSource = gaj.loadJournalDetailGRN(editID);
            gvList.DataBind();
        }
        protected void GridView_PreRender(object sender, EventArgs e)
        {

            try
            {
                var gridView = (GridView)sender;
                var header = (GridViewRow)gridView.Controls[0].Controls[0];

                header.Cells[1].Visible = false;
                header.Cells[2].ColumnSpan = 2;
                header.Cells[2].Text = "Acc / CC";
            }
            catch (Exception ex)
            { }



        }
    }
}